package threeAddressGenerator;

public class Quadruple {

    public enum Op{
        TYPE,
        EXIT,   // when function or method, arg_1 is function or method name
        LOAD,   // get a member variable, arg_1 is a struct or other, arg_2 is its member variable, and save to result
        FUNC,   // declare a function or method, arg_1 is function or method name
        ALLOC,  // alloc a memory for symbol, arg_1 is symbol name, arg_2 is size
        CALL,   // when call a function or method, arg_1 is function or method name
        PARAM,  // declare a parameter for a function or method, arg_1 is parameter name
        ADD,    // add, if arg_2 exist, save arg_1 + arg_2 to result, else save +arg_1 to result
        MINUS,  // minus, if arg_2 exist, save arg_1 - arg_2 to result, else save -arg_1 to result
        MUL,    // mul, save arg_1 * arg_2 to result
        DIV,    // div, save arg_1 / arg_2 to result
        AND,    // and, save arg_1 & arg_2 to result
        MOD,    // mod, save arg_1 % arg_2 to result
        LSHIFT, // left shift, save arg_1 << arg_2 to result
        RSHIFT, // right shift, save arg_1 >> arg_2 to result
        ADDRESS,    // get address, save arg_1 address to result
        AND_XOR,    // and_xor, save arg_1 &^ arg_2 to result
        XOR,    // xor, save arg_1 ^ arg_2 to result
        OR, // or, save arg_1 | arg_2 to result
        EQUALS, // equals, save arg_1 == arg_2 to result
        NOT_EQUALS, // not_equals, save arg_1 != arg_2 to result
        NOT,    // not, save !arg_1 to result
        LESS,   // less, save arg_1 < arg_2 to result
        LESS_EQUALS,    // less_equals, save arg_1 <= arg_2 to result
        GREATER,    // greater, save arg_1 > arg_2 to result
        GREATER_EQUALS, // greater_equals, save arg_1 >= arg_2 to result
        LOGICAL_AND,    // logical_and, save arg_1 && arg_2 to result
        LOGICAL_OR, // logical_or, save arg_1 || arg_2 to result
        ASSIGN, // when assign a symbol, arg_1 is source, arg_2 is type, result is des
        BIAS,   // get an element from array or array-like type, arg_1 is array name, arg_2 is bias, result is des
        ARGUMENT,   // declare an argument for a function or method call, arg_1 is argument name
        RESULT,  // declare a result for function or method, result is des
        LABEL,   // labeling block, result is label's name
        GO,
        FJUMP,  //Conditional Jump
        RETURN,  //only return 1
        BREAK,
        GOTO,   // Goto, result is the label. Equivalent to unconditional jumping
        PRINT,
        SCAN
    }

    private Op op;
    private String arg_1;

    private String arg_2;
    private String result;

    public Quadruple() {
        this.op = null;
        this.arg_1 = null;
        this.arg_2 = null;
        this.result = null;
    }

    public Quadruple(Op op, String arg_1, String arg_2, String result) {
        this.op = op;
        this.arg_1 = arg_1;
        this.arg_2 = arg_2;
        this.result = result;
    }

    public Op getOp() {
        return op;
    }

    public void setOp(Op op) {
        this.op = op;
    }

    public String getArg_1() {
        return arg_1;
    }

    public void setArg_1(String arg_1) {
        this.arg_1 = arg_1;
    }

    public String getArg_2() {
        return arg_2;
    }

    public void setArg_2(String arg_2) {
        this.arg_2 = arg_2;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    @Override
    public String toString() {
        return "(" +
                "op=" + op +
                ", arg_1=" + arg_1 +
                ", arg_2=" + arg_2 +
                ", result=" + result +
                '}';
    }
}
